package com.itheima.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itheima.pojo.Result;
import com.itheima.pojo.Student;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

@Mapper
public interface StudentMapper extends BaseMapper<Student> {


    List<Student> findAll(@Param("name") String name, @Param("degree") String degree , @Param("clazzId") Integer clazzId);

    void deleteStudent(@Param("ids") List<Integer> ids);

    @Insert("INSERT INTO student (name, no, gender, phone, degree, clazz_id, id_card, is_college, address) " +
            "VALUES (#{name}, #{no}, #{gender}, #{phone}, #{degree}, #{clazzId}, #{idCard}, #{isCollege}, #{address})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    void postStudent(Student student);
    //数据回显
    Student getStudentById(Integer id);
    //更新数据
    void putStudent(Student student);

    @Update("update student set violation_score = violation_score +1 , violation_count = violation_count  + 1 where " +
            "student.id = #{id} ")
    void disposeById(@Param("id") Integer id, @Param("score") Integer score);

    List<Map<String, Object>> stuentDegreeDate();

    List<Map<Student, Object>> studentCountData();
}
